Imports System.Data.SqlClient

Public Class Plan : Implements IBusquedaFiltrado

    Private IdPlan As Integer
    Private Nombre As String
    Private Estado As Estado
    Private FechaAlta As Date
    Private FechaVto As Date
    Private Coeficiente As Double
    Private Cobertura As Double
    Public Property IdPlanP() As Integer
        Get
            Return IdPlan
        End Get
        Set(ByVal value As Integer)
            IdPlan = value
        End Set
    End Property
    Public Property NombreP() As String
        Get
            Return Nombre
        End Get
        Set(ByVal value As String)
            Nombre = value
        End Set
    End Property
    Public Property EstadoP() As Estado
        Get
            Return Estado
        End Get
        Set(ByVal value As Estado)
            Estado = value
        End Set
    End Property
    Public Property FechaAltaP() As Date
        Get
            Return FechaAlta
        End Get
        Set(ByVal value As Date)
            FechaAlta = value
        End Set
    End Property
    Public Property FechaVtoP() As Date
        Get
            Return FechaVto
        End Get
        Set(ByVal value As Date)
            FechaVto = value
        End Set
    End Property
    Public Property CoefP() As Double
        Get
            Return Coeficiente
        End Get
        Set(ByVal value As Double)
            Coeficiente = value
        End Set
    End Property
    Public Property CoberturaP() As Double
        Get
            Return Cobertura
        End Get
        Set(ByVal value As Double)
            Cobertura = value
        End Set
    End Property
    Public Sub New()
        IdPlan = 0
        Nombre = ""
        Estado = Nothing
        FechaAlta = Nothing
        FechaVto = Nothing
        Coeficiente = 0
        Cobertura = 0

    End Sub

    Public Function Agregar(ByRef con As ConexionBD) As Boolean Implements IBusquedaFiltrado.Agregar
        Return True
    End Function

    Public Function Buscar(ByVal id As Integer, ByRef con As ConexionBD) As Boolean Implements IBusquedaFiltrado.Buscar
        'Dim comando As SqlDataAdapter
        'Dim rs As DataTableReader
        'Dim dato As DataTable
        'Dim sql As String
        'Dim lResp As Boolean = False



        'sql = String.Format("SELECT * FROM Plan WHERE idPlan ={0}", id)
        'comando = New SqlDataAdapter(sql, con.ConexionBase)
        'dato = New DataTable("Plan")
        'comando.Fill(dato)
        'rs = dato.CreateDataReader()
        'comando.Dispose()
        'dato.Dispose()


        'If rs.Read Then
        '    IdPlan = System.Convert.ToInt16(rs("idPlan"))
        '    Me.NombreP = rs("nombre").ToString

        '    Dim ObjEstadoP As Estado = New Estado()
        '    ObjEstadoP.Buscar(rs("IdEstado"), con)
        '    EstadoP = ObjEstadoP

        '    Me.FechaAltaP = rs("FechaAlta")
        '    Me.FechaVtoP = rs("FechaVto")
        '    Me.CoefP = rs("coefciente")
        '    Me.CoberturaP = rs("cobertura")

        '    lResp = True
        'Else
        '    lResp = False
        'End If
        'rs.Close()
        'Return lResp
        Return True
    End Function
    Public Function Eliminar(ByVal id As Integer, ByRef con As ConexionBD) As Boolean Implements IBusquedaFiltrado.Eliminar
        Return True
    End Function

    Public Function Modificar(ByRef con As ConexionBD) As Boolean Implements IBusquedaFiltrado.Modificar
        Return True
    End Function
    Public Function BuscarDatos(ByRef con As ConexionBD) As DataSet

        Dim sql As String = ""
        Dim adapter As SqlDataAdapter = Nothing
        Dim datos As DataSet = New DataSet()
        sql = "SELECT * FROM PLAN "

        'sql = "SELECT P.nombre FROM PLAN P,OBRASOCIAL O,OBRASOCPLAN OP WHERE P.IdPlan=OP.IdPlan and O.IdObraSocial=OP.IdObraSocial"
        adapter = New SqlDataAdapter(sql, con.ConexionBase)
        adapter.Fill(datos, "plan")

        Return datos
    End Function
End Class
